/**
 * Class: Chain
 *
 * Purpose: Head element for a group of ChainLink particles
 *
 * Created: Feb 13, 2010 @ 10:07:29 AM
 * @author Ken Scott
 */
package org.openfantasia.ps.particle;

import org.openfantasia.util.math.DPoint3;

public class Chain extends ChainLink {

	public Chain(int length, DPoint3 position, DPoint3 spacing, DPoint3 twist, double mass, DPoint3 gravity, DPoint3 stiffness, DPoint3 damping) {
		super(position, mass, gravity, stiffness, damping);

		ChainLink c = this;
		DPoint3 pos = position.copy();
		for (int i = 0; i < length - 1; i++) {
			ChainLink next = new ChainLink(pos.add(spacing).copy(), mass, gravity, stiffness, damping);
			DPoint3 orient = c.getOrientation().copy().add(twist);
			next.setOrientation(orient);
			c.setDownLink(next);
			next.setUpLink(c);
			c = next;
		}
	}
}
